package com.ruoyi.mymod.controller.check;


import com.alibaba.fastjson2.JSONObject;
import com.google.gson.Gson;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.mymod.service.ICheEntryService;
import com.ruoyi.mymod.service.IChickenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;


/**
 * 测试功能
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/che")
public class CheEntryController extends BaseController
{

    @Autowired
    private ICheEntryService cheEntryService;
    /**
     * 获取菜单列表
     */
    @GetMapping("/getEntry")
    public AjaxResult getEntry() throws Exception {
        String entrys = cheEntryService.getEntry();
        return success(entrys);
    }

    @GetMapping("/setEntry")
    public AjaxResult setEntry(@RequestParam(required = false) String phone, @RequestParam(required = false) String nowdate) throws Exception {
        String res = cheEntryService.setEntry(phone, nowdate);
        return success(res);
    }

    @GetMapping("/getOperators")
    public AjaxResult getOperators(@RequestParam(required = false) String phone) throws Exception {
        String operators = cheEntryService.getOperators(phone);
        return success(operators);
    }


    @GetMapping("/getFrequencys")
    public AjaxResult getFrequencys() throws Exception {
        String frequencys = cheEntryService.getFrequencys();
        return success(frequencys);
    }

    @GetMapping("/addChe")
    public AjaxResult addChe(@RequestParam(required = false) String phone, @RequestParam(required = false) String oper, @RequestParam(required = false) String nowdate, @RequestParam List<String> completedayArry,@RequestParam List<String> completeweekArry,@RequestParam List<String> completemonthArry,@RequestParam String completeString, @RequestParam List<String> uncompletedayArry,@RequestParam List<String> uncompleteweekArry,@RequestParam List<String> uncompletemonthArry) throws Exception {
        String res = cheEntryService.addChe(phone, oper, nowdate, completedayArry,completeweekArry,completemonthArry,completeString,uncompletedayArry,uncompleteweekArry,uncompletemonthArry);
        return success(res);
    }

    @GetMapping("/getHasChecked")
    public AjaxResult getHasChecked(@RequestParam(required = false) String phone, @RequestParam(required = false) String oper, @RequestParam(required = false) String nowdate) throws Exception {
        String res = cheEntryService.getHasChecked(phone, oper, nowdate);
        return success(res);
    }

    @GetMapping("/getUsers")
    public AjaxResult getUsers() throws Exception {
        String frequencys = cheEntryService.getUsers();
        return success(frequencys);
    }


    @GetMapping("/checkByUser")
    public AjaxResult checkByUser(@RequestParam(required = false) String phone, @RequestParam(required = false) String checkdate) throws Exception {
        String res = cheEntryService.checkByUser(phone, checkdate);
        return success(res);
    }

    @GetMapping("/getPiginfo")
    public AjaxResult getPiginfo(@RequestParam(required = false) String phone) throws Exception {
        String operators = cheEntryService.getPiginfo(phone);
        return success(operators);
    }


    @GetMapping("/getSowWarm")
    public AjaxResult getSowWarm(@RequestParam(required = false) String phone) throws Exception {
        List<String> operators = cheEntryService.getSowWarm(phone);
        return success(operators);
    }


}
